package jdbc;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;

public class TestSQL {
    public static void main(String[] args) throws Exception {
        Class.forName("com.mysql.cj.jdbc.Driver");
        //与数据库连接
        Connection connection= DriverManager.getConnection(
                //格式：jdbc:mysql://主机地址信息/数据库名？参数列表
                "jdbc:mysql://localhost:3306/tedu?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true",
                "root","root");
        System.out.println("与数据库建立连接");
        Statement statement=connection.createStatement();//创建执行sql语句的对象

        Student1 student1=new StudentIm();
        statement.executeUpdate(student1.addStudent());//添加学生
        //statement.executeUpdate(student1.deleteStudent("qwe"));//删除学生
        //statement.executeUpdate(student1.updateStudent("asd"));//修改学生信息
        //statement.executeQuery(student1.queryAllStudent());//查询所有学生信息
        //statement.executeQuery(student1.queryStudentById(2));//根据id查询学生信息








    }
}
